'use strict';

const Controller = require('egg').Controller;

class LivegiftController extends Controller {
    async list() {
        this.ctx.validate({
          liveid: {
            type: "int",
            required: true,
            defValue: "",
            desc: "liveid",
          },
        })
        const res = await this.app.model.LiveGift.findAll({
          where: {
            live_id: this.ctx.request.body.liveid
          },
          include:[{
            model:this.app.model.User,
      
            attributes:["id","username","avatar","name"]
          },
          {
            model:this.app.model.Gift,
      
            attributes:["id","name","image"]
          },
          {
            model:this.app.model.Live,
      
            attributes:["id","title","cover"]
          }]
        })
       
        this.ctx.apiSuccess(res,"获取成功",200)
      }
}

module.exports = LivegiftController;
